import UtilFuncs from "../../common/tools/utilfuncs";
var funcs = UtilFuncs.UtilFuncs;
import {CoordTRFUtil}  from "../../common/tools/coordtool";
const disRadius = 20;
const absorbColorStr = 'rgb(' + 0 + "," + 255 + "," + 0 + ")";

var IncludeAngleUtil = {}

IncludeAngleUtil.display = function(ln1pt1,ln1pt2,ln2pt1,ln2pt2,map, mapInfo) {
    let vct1 = funcs.getVector(ln1pt1, ln1pt2);
    let vct2 = funcs.getVector(ln2pt1, ln2pt2);

    let stAngle = vct1.angleFrmXAxisPositiveDir();
    let endAngle = vct2.angleFrmXAxisPositiveDir();

    let cntpt = { x: ln1pt1.x, y: ln1pt1.y };
    var screenCnt = CoordTRFUtil.world2Screen(cntpt, mapInfo);
    let stAngleRad = Math.PI * 2 - funcs.degree2Radian(stAngle);
    let endAngleRad = Math.PI * 2 - funcs.degree2Radian(endAngle);

    map.beginPath();
    map.lineWidth = 1;
    map.strokeStyle = absorbColorStr;
    map.arc(screenCnt.x, screenCnt.y, disRadius, stAngleRad, endAngleRad, true);
    map.stroke();
    map.closePath();

    map.fillStyle = absorbColorStr;
    var canvasfont = "12px 仿宋";
    map.font = canvasfont;
    let deta = endAngle - stAngle;
    if (deta < 0) {
        deta += 360;
    }
    let text = deta.toFixed(2);
    let tx = screenCnt.x;
    let ty = screenCnt.y;
    map.fillText(text, tx, ty);
}

export {IncludeAngleUtil}